package com.ruoyi.pcwl.domain.query;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;


import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
@ApiModel("分页请求基础类")
public class BaseRequest<T> implements Serializable {

    @ApiModelProperty("页码")
    private int current=1;

    @ApiModelProperty("每页显示多少条")
    private int size=10;

    @ApiModelProperty("排序方式")
    private String orderBy;

    /** 请求参数 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private Map<String, Object> params;

    /**
     * 针对 mybatis-plus分页对象
     * @return
     */
    public Page<T> getPage() {
        return new Page<T>(current,size);
    }

    /**
     * activiti分页
     * @return
     */
    public Integer getFirstResult() {
        return (current - 1) * size;
    }

    public Map<String, Object> getParams()
    {
        if (params == null)
        {
            params = new HashMap<>();
        }
        return params;
    }

    public void setParams(Map<String, Object> params)
    {
        this.params = params;
    }

}
